package com.tjshop.android.model;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public abstract class BaseObject {
	public abstract void parse(JSONObject data);

	public int getInt(JSONObject obj, String id) {
		try {
			if (obj.has(id)) {
				return obj.getInt(id);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return 0;
	}

	public String getString(JSONObject obj, String id) {
		try {
			if (obj.has(id)) {
				return obj.getString(id);
			}
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return null;
	}

	public abstract void parse(JSONArray data);
}
